<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>javascript</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box
    }
    body {
      font-size: 14px;
      padding: 20px;
    }
    ul li {
      line-height: 30px;
      text-decoration:line-through
    }
  </style>
</head>
<body>
  <div id="textDiv">
    我是文本字符串哈哈文本
  </div>  
  <input typee="text" value="" />
</body>
<script>
  var d = document.getElementById('textDiv');
  var t = d.innerHTML;
  document.getElementsByTagName('input')[0].oninput = function(e) {
    var re = new  RegExp(e.target.value, 'g');
    var s = t.replace(re, "<span style='color: red; text-decoration: line-through'>"+e.target.value+"</span>");
    console.log(s)
    d.innerHTML = s;
  }
</script>
</html>